package uit.com.project.iCampus.model;

import java.util.HashSet;
import java.util.Set;

import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

@XmlRootElement
public class BuildingInfo {

	private long idBuilding;
	private BuildingTypeEnum buidingTypeEnum;
	private String buildingName;
	private float longitude;
	private float latitude;
	private String detail;
	private Set<BuildingRate> buidingRates = new HashSet<BuildingRate>(0);
	
	@SuppressWarnings("unused")
	private double rateDouble;

	public BuildingInfo() {
	}

	public BuildingInfo(BuildingTypeEnum buidingTypeEnum, String buildingName,
			float longitude, float latitude, String detail) {
		this.buidingTypeEnum = buidingTypeEnum;
		this.buildingName = buildingName;
		this.longitude = longitude;
		this.latitude = latitude;
		this.detail = detail;
	}

	
	public BuildingInfo(long idBuilding, BuildingTypeEnum buidingTypeEnum,
			String buildingName, float longitude, float latitude, String detail) {
		super();
		this.idBuilding = idBuilding;
		this.buidingTypeEnum = buidingTypeEnum;
		this.buildingName = buildingName;
		this.longitude = longitude;
		this.latitude = latitude;
		this.detail = detail;
	}

	/**
	 * @return the idBuilding
	 */
	public long getIdBuilding() {
		return idBuilding;
	}

	/**
	 * @param idBuilding the idBuilding to set
	 */
	public void setIdBuilding(long idBuilding) {
		this.idBuilding = idBuilding;
	}

	/**
	 * @return the buidingTypeEnum
	 */
	public BuildingTypeEnum getBuidingTypeEnum() {
		return buidingTypeEnum;
	}

	/**
	 * @param buidingTypeEnum
	 *            the buidingTypeEnum to set
	 */
	public void setBuidingTypeEnum(BuildingTypeEnum buidingTypeEnum) {
		this.buidingTypeEnum = buidingTypeEnum;
	}

	/**
	 * @return the buildingName
	 */
	public String getBuildingName() {
		return buildingName;
	}

	/**
	 * @param buildingName
	 *            the buildingName to set
	 */
	public void setBuildingName(String buildingName) {
		this.buildingName = buildingName;
	}

	/**
	 * @return the longitude
	 */
	public float getLongitude() {
		return longitude;
	}

	/**
	 * @param longitude
	 *            the longitude to set
	 */
	public void setLongitude(float longitude) {
		this.longitude = longitude;
	}

	/**
	 * @return the latitude
	 */
	public float getLatitude() {
		return latitude;
	}

	/**
	 * @param latitude
	 *            the latitude to set
	 */
	public void setLatitude(float latitude) {
		this.latitude = latitude;
	}

	/**
	 * @return the detail
	 */
	public String getDetail() {
		return detail;
	}

	/**
	 * @param detail
	 *            the detail to set
	 */
	public void setDetail(String detail) {
		this.detail = detail;
	}

	/**
	 * @return the buidingRates
	 */
	@XmlTransient
	public Set<BuildingRate> getBuidingRates() {
		return buidingRates;
	}

	/**
	 * @param buidingRates the buidingRates to set
	 */
	public void setBuidingRates(Set<BuildingRate> buidingRates) {
		this.buidingRates = buidingRates;
	}

	/**
	 * @return the rateDouble
	 */
	public double getRateDouble() {
		int rateSize =  buidingRates.size();
		double pointAllRates = 0.0;
		if (rateSize != 0) {
			for (BuildingRate buildingRate : buidingRates) {
				pointAllRates += buildingRate.getPoint();
			}
			return pointAllRates / rateSize;
		}
		
		return 0.0;
	}

	/**
	 * @param rateDouble the rateDouble to set
	 */
	public void setRateDouble(double rateDouble) {
		this.rateDouble = rateDouble;
	}

}
